<template>
  <div class="mod-config">
    <basic-container>
      <navigationHeTong
        :sign="{ a: false, b: false, c: false, d: false, e: true, f: false }"
      ></navigationHeTong>
      <div class="boxsty zhiBiao" v-if="zhiShow == 1">
        <div :height="searchheight" v-if="programInterface != 'jgtb'">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
              label-width="120px"
            >
              <el-form-item label="合同名称">
                <el-input
                  v-model="dataForm.contractName"
                  placeholder="合同名称"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>

              <el-form-item label="受约人姓名">
                <el-input
                  v-model="dataForm.shouyueName"
                  placeholder="受约人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人岗位">
                <el-input
                  v-model="dataForm.shouyueZhiwu"
                  placeholder="受约人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人职级">
                <el-input
                  v-model="dataForm.ryZjmc"
                  placeholder="受约人职级"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="发约人姓名">
                <el-input
                  v-model="dataForm.fayueName"
                  placeholder="发约人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="合同状态">
                <el-select
                  style="width: 150px"
                  v-model="dataForm.contractAuditStatus"
                  placeholder="请选择"
                  :clearable="true"
                >
                  <el-option value="" label="全部"></el-option>

                  <el-option value="11" label="结果填报中"></el-option>
                  <el-option value="111" label="填报审核驳回"></el-option>
                  <el-option value="12" label="结果填报审核中"></el-option>
                  <el-option value="13" label="结果汇总完成"></el-option>
                  <el-option value="14" label="领导审核中"></el-option>
                  <el-option value="15" label="领导审核完成"></el-option>
                  <el-option value="16" label="已结束"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList(1)"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>

        <div class="avue-crud">
          <div class="border-top-theme">
            <div class="mt10">
              业绩合同
              <span>
                <el-radio v-model="radio" label="1">个人</el-radio>
                <el-radio v-model="radio" label="2">机构</el-radio>
              </span>
              <span
                style="margin-left: 160px"
                v-if="permissions.hetongrenwu_hetonghtxxdjb_scope"
              >
                数据范围
                <el-radio-group v-model="radioTwo">
                  <el-radio
                    v-for="(item, index) in radioTwoList"
                    :key="index + 111"
                    :label="item.value"
                    >{{ item.name }}</el-radio
                  >
                </el-radio-group>
              </span>
              <span style="float: right">
                <el-button plain type="primary" @click="exportExcel"
                  >导出</el-button
                >
                <el-button plain type="primary" @click="temanagementBtn"
                  >模板管理</el-button
                >
                <el-button plain type="primary" @click="handleFillAll"
                  >批量填报</el-button
                >
                <el-button
                  plain
                  type="primary"
                  @click="openSubmitAllDialog"
                  v-loading.fullscreen.lock="fullscreenLoading"
                  >批量提交</el-button
                >
              </span>
            </div>
          </div>
          <el-table
            ref="reftable"
            style="width: 100%; margin-top: 20px"
            :data="dataList"
            @selection-change="handleSelectionChange"
            border
            v-if="rednermsg"
            v-loading="dataListLoading"
            @row-click="unfoldBtn"
          >
            <el-table-column
              type="selection"
              width="55"
              header-align="center"
              align="center"
              :selectable="checkboxSelect"
            ></el-table-column>
            <el-table-column
              type="index"
              width="80"
              header-align="center"
              align="center"
              label="序号"
            ></el-table-column>
            <el-table-column
              prop="contractName"
              header-align="center"
              show-overflow-tooltip
              align="center"
              min-width="200"
              label="合同名称"
            >
              <template slot-scope="scope">
                <span
                  @click="openZhibiao(scope.row)"
                  style="color: #0e258c; cursor: pointer"
                  >{{ scope.row.contractName }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 2"
              prop="jigouName"
              header-align="center"
              show-overflow-tooltip
              align="center"
              label="机构名称"
            >
              <template slot-scope="scope">
                <span>{{ scope.row.jigouName }}</span>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueCode"
              header-align="center"
              align="center"
              min-width="150"
              label="受约人编号"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueCode.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueCode).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueCode).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueCode).length > 2 && index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueName"
              header-align="center"
              align="center"
              min-width="120"
              label="受约人姓名"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueName).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueName).length > 2 && index === 0
                    "
                    style="margin-top: 10px; margin-right: 0px"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueDeptName"
              header-align="center"
              align="center"
              min-width="150"
              label="受约人单位"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueDeptName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(
                    scope.row.shouyueDeptName
                  ).slice(0, 2)"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueDeptName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueDeptName).length > 2 &&
                      index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1 && shows == 1"
              prop="shouyueZhiwu"
              header-align="center"
              align="center"
              min-width="180"
              label="受约人岗位"
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至受约人职级">
                  <span
                    ><i
                      @click="switchBtn(2)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >受约人岗位</span
                  >
                </el-tooltip>
              </template>
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueZhiwu.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueZhiwu).slice(
                    0,
                    2
                  )"
                  :key="index + 222"
                >
                  <span>{{ validatenull(item) ? "-" : item | ellipsis }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1 && shows == 2"
              prop="ryZjmc"
              header-align="center"
              align="center"
              min-width="180"
              label="受约人职级"
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至受约人岗位">
                  <span
                    ><i
                      @click="switchBtn(1)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >受约人职级</span
                  >
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column
              prop="fayueName"
              header-align="center"
              align="center"
              min-width="120"
              label="发约人姓名"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.fayueName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.fayueName).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.fayueName).length"
                    :max="9"
                    v-if="cutout(scope.row.fayueName).length > 2 && index === 0"
                    style="margin-top: 10px; margin-right: 0px"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              prop="fayueZhiwu"
              header-align="center"
              align="center"
              min-width="180"
              label="发约人岗位"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.fayueZhiwu.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.fayueZhiwu).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <span>{{
                    (validatenull(item) ? "-" : item) | ellipsis
                  }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              prop="faqiType"
              header-align="center"
              align="center"
              label="发起类型"
              min-width="150"
              :formatter="tbFormater"
            >
            </el-table-column>
            <el-table-column
              prop="contractAuditStatus"
              header-align="center"
              align="center"
              min-width="110"
              label="合同状态"
              :formatter="contractAuditFormater"
            >
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <el-dialog title="请选择：" :visible.sync="chooseVisible" width="30%">
        <div style="display: flex; justify-content: space-around">
          <el-button plain type="warning" @click="customBtn"
            >自定义流程</el-button
          >
          <el-dropdown>
            <el-button plain type="primary" size="small">
              模板<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu v-if="temList.length > 0">
              <el-dropdown-item v-for="(item, index) in temList" :key="index"
                ><span @click="temBtn(item)">{{
                  item.templateName
                }}</span></el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-dialog>
      <temanagementDialog
        :temanagementDialogData="temanagementDialogData"
      ></temanagementDialog>
      <sortingPerChooseDialog
        :sortingPerChooseDialogData="sortingPerChooseDialogData"
        @sortingPerChooseDialogChild="sortingPerChooseDialogChild"
      ></sortingPerChooseDialog>
      <!-- 指标维护-->
      <HeTongZhiBiaoTable
        v-if="zhiShow == 2"
        ref="hetongzhibiaoTable"
        :hetong="hetong"
        :hetongzhibiaoTable="hetongzhibiaoTable"
        :programInterface="programInterface"
        v-on:fnBackOldPage="fnBackOldPage"
      ></HeTongZhiBiaoTable>
      <!-- 批量填报-->
      <TianBaoTable
        v-if="zhiShow == 3"
        :tianBaoTable="tianBaoTable"
        :ids="ids"
        showType="1"
        :radio="radio"
        :ndids="ndids"
        v-on:fnBackOldPage="fnBackOldPage"
      ></TianBaoTable>
      <customDialog
        :customDialogData="customDialogData"
        @customDialogChildren="customDialogChildren"
      ></customDialog>
    </basic-container>
  </div>
</template>

<script>
import {
  fetchListjg,
  delObj,
  jgtbExportExcel,
  getListMb,
  handleSubmitAll,
} from "@/api/hetongrenwu/hetongjgtb";
import HeTongZhiBiaoTable from "@/views/hetongrenwu/components/hetongzhibiao-table.vue";
import customDialog from "@/views/hetongrenwu/hetong/hetongyeji/hetongnd/customDialog.vue";
import TianBaoTable from "@/views/hetongrenwu/components/tianbao-table.vue";
import { radioTwoList } from "@/api/hetongrenwu/hetonghtxxdjb";
import { validatenull } from "@/util/validate";
import { mapGetters } from "vuex";
import sortingPerChooseDialog from "@/views/hetongrenwu/components/sortingPerChooseDialog.vue";
import temanagementDialog from "@/views/hetongrenwu/hetong/hetongyeji/hetongnd/temanagementDialog.vue";
import { checkSign } from "@/api/hetongrenwu/hetongjghz";

export default {
  components: {
    HeTongZhiBiaoTable,
    TianBaoTable,
    sortingPerChooseDialog,
    temanagementDialog,
    customDialog,
  },
  data() {
    return {
      hetongId: Number,
      str: Number,
      dataForm: {
        key: "",
      },
      customDialogData: {},
      sortingPerChooseDialogData: {},
      temanagementDialogData: {},
      searchadvanced: true,
      searchheight: "0",
      dataList: [],
      temList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      fullscreenLoading: false,
      addOrUpdateVisible: false,
      radio: "1",
      radioTwo: "-1",
      zhiShow: "1",
      tianBaoTable: {},
      hetongzhibiaoTable: {},
      radioTwoList: radioTwoList,
      hetong: {},
      ids: [],
      programInterface: "",
      dialogVisiblePiLiang: false,
      pilinangform: {},
      ryZjmc: "",
      jgtbzt: "",
      chooseVisible: false,
      iszbsh: Number,
      type: Number,
      ndids: [],
      shows: 1,
      rednermsg: true,
    };
  },
  watch: {
    radio(value) {
      if (value) {
        this.getDataList();
      }
    },
    radioTwo(value) {
      if (value) {
        this.getDataList();
      }
    },
  },
  filters: {
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 8) {
        return value.slice(0, 8) + "...";
      }
      return value;
    },
  },
  created() {
    let params = this.$route.query;
    if (!validatenull(params)) {
      this.radioTwo = params.radioTwo;
    }
    this.getDataList();
    this.fngetListMb();
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  methods: {
    init(
      formInfo,
      formInfoDetailed,
      formData,
      GUID,
      wfYwMain,
      wfYwStream,
      dqYwStream,
      dqTask
    ) {
      this.programInterface = dqTask.programInterface;
      //console.log(dqTask.programInterface);
      this.dataForm.id = wfYwMain.ywLyid;
      this.getDataList();
    },
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    statusFormater(row, column) {
      const status = row.contFillStatus;
      if (status == 0) {
        return "未填报";
      } else if (status == 1) {
        return "待预填报";
      } else if (status == 2) {
        return "已预填报";
      } else if (status == 3) {
        return "待填报";
      } else if (status == 4) {
        return "已填报";
      } else if (status == 5) {
        return "预填报审核中";
      } else if (status == 6) {
        return "填报审核中";
      } else if (status == 7) {
        return "预填报已退回";
      } else if (status == 8) {
        return "填报已退回";
      }
    },
    jgzbFormater(row, column) {
      const jgzbStatus = row.jgzbStatus;
      if (jgzbStatus == 0) {
        return "未提交";
      } else if (jgzbStatus == 1) {
        return "填报中";
      } else if (jgzbStatus == 2) {
        return "已退回";
      } else if (jgzbStatus == 3) {
        return "已审核";
      } else if (jgzbStatus == 4) {
        return "结果审核中";
      } else if (jgzbStatus == 5) {
        return "结果审核退回";
      } else if (jgzbStatus == 6) {
        return "结果审核通过";
      } else if (jgzbStatus == 7) {
        return "已结束";
      }
    },
    unfoldBtn(row) {
      row.rowshows = !row.rowshows;
      this.rednermsg = false;
      this.$nextTick(() => {
        this.rednermsg = true;
      });
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      fetchListjg(
        Object.assign({
          fayueName: this.dataForm.fayueName,
          shouyueName: this.dataForm.shouyueName,
          shouyueZhiwu: this.dataForm.shouyueZhiwu,
          contractAuditStatus: this.dataForm.contractAuditStatus,
          current: this.pageIndex,
          size: this.pageSize,
          pageType: "htjgtb",
          type: this.radio,
          isbenbu: this.radioTwo,
          id: this.dataForm.id,
          ryZjmc: this.dataForm.ryZjmc,
          contractName: this.dataForm.contractName,
        })
      ).then((response) => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
        this.dataList.forEach((ele) => {
          ele.rowshows = true;
        });
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 新增 / 修改
    addOrUpdateHandle(id) {
      this.addOrUpdateVisible = true;
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(id);
      });
    },
    fngetListMb() {
      var params = {
        menuType: "结果填报",
        tagName: "业绩合同",
      };
      getListMb(params).then((res) => {
        this.temList = res.data.data;
      });
    },
    // 删除
    deleteHandle(id) {
      this.$confirm("是否确认删除ID为" + id, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return delObj(id);
        })
        .then((data) => {
          this.$message.closeAll();
          this.$message.success("删除成功");
          this.getDataList();
        });
    },
    //子集信息
    fnBackOldPage(data) {
      if (data == "返回原页面") {
        this.zhiShow = 1;
        this.getDataList();
      }
    },
    //新增子集返回的数据(关闭修改页面，打开指标库维护)
    openZhibiao(data) {
      ////console.log(data)
      this.hetong = data;
      this.jgtbzt = data.contractAuditStatus;
      this.addOrUpdateVisible = false;
      this.zhiShow = 2;
      this.hetongzhibiaoTable = {
        pageTitle: "业绩合同",
        page: "tbfq",
        showSearch: true,
        str: 2,
        ndId: data.id,
        radioType: this.radio,
        hetongId: data.htId,
        type: "jgtb",
        lastPage: "jgtb",
        operationType: data.faqiType,
        jgtbstatus: data.contractAuditStatus,
        isEditRow:
          data.contractAuditStatus == 11 || data.contractAuditStatus == 111
            ? true
            : false,
        rows: data,
      };
      ////console.log(data.contractAuditStatus)
      var data = {
        lastPage: "jgtb",
        showSearch: true,
        ndId: data.id,
        // jgtbstatus: this.jgtbzt
      };
      ////console.log(this.jgtbzt + "======----aaa");
      this.$nextTick(() => {
        this.$refs.hetongzhibiaoTable.init(data);
      });
    },
    //打开批量填报
    handleFillAll() {
      if (this.$refs.reftable.selection.length < 1) {
        this.$message.closeAll();
        this.$message.error("请至少选中一条合同");
        return;
      }
      var ids = this.$refs.reftable.selection.map((item) => {
        return item.htId;
      });
      this.ids = ids;
      var taskIds = "";
      this.$refs.reftable.selection.forEach((item) => {
        taskIds = taskIds + item.taskId + ",";
      });
      var ndids = this.$refs.reftable.selection.map((item) => {
        return item.id;
      });
      this.ndids = ndids;
      //console.log(taskIds)
      this.zhiShow = 3;
      this.tianBaoTable = {
        lastPage: "jgtb",
        taskIds: taskIds,
      };
    },
    //打开批量提交弹框
    openSubmitAllDialog() {
      const rows = this.$refs.reftable.selection;
      if (rows.length == 0) {
        this.$message.closeAll();
        this.$message({
          type: "info",
          message: "请至少选择一条数据提交!",
        });
        return false;
      }
      this.$confirm("是否跳过结果审核", "提示", {
        confirmButtonText: "是",
        cancelButtonText: "否",
        type: "warning",
      })
        .then((res) => {
          this.fullscreenLoading = true;
          this.iszbsh = 0;
          const rows = this.$refs.reftable.selection;
          var params = {
            isjgtbsh: this.iszbsh,
            rows: rows,
          };
          handleSubmitAll(params)
            .then((res) => {
              this.fullscreenLoading = false;
              this.$message.closeAll();
              this.$message.success("提交成功");
              this.getDataList();
            })
            .catch(() => {
              this.$message.closeAll();
              this.$message({
                type: "error",
                message: "提交失败!",
              });
            });
        })
        .catch(() => {
          this.iszbsh = 1;
          this.chooseVisible = true;
        });
    },
    customBtn() {
      this.chooseVisible = false;
      this.type = 2;
      this.customDialogData = {
        dialogVisible: true,
        type: this.type,
        iszbsh: this.iszbsh,
        rows: this.$refs.reftable.selection,
        menuType: "jgtb",
      };
    },
    temBtn(e) {
      //console.log(e)
      this.fullscreenLoading = true;
      this.type = 1;
      var params = {
        type: this.type,
        isjgtbsh: this.iszbsh,
        rows: this.$refs.reftable.selection,
        templateId: e.id,
      };
      handleSubmitAll(params).then((res) => {
        this.fullscreenLoading = false;
        this.$message.closeAll();
        this.$message.success("操作成功");
        this.chooseVisible = false;
        this.getDataList();
      });
    },
    customDialogChildren(data) {
      this.getDataList();
    },
    sortingPerChooseDialogChild(data) {
      this.getDataList();
    },
    temanagementBtn() {
      this.temanagementDialogData = {
        dialogVisible: true,
        type: "结果填报",
      };
    },
    //批量提交
    handleSubmitAll() {
      var rows = this.$refs.reftable.selection;
      if (rows.length > 0) {
        this.$confirm("是否要提交选择的" + rows.length + "条结果?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            var params = {
              rows: rows,
              sonhq: this.pilinangform.sonhq,
            };
            handleSubmitAll(params)
              .then((res) => {
                this.dialogVisiblePiLiang = false;
                this.$message.closeAll();
                this.$message({
                  type: "info",
                  message: res.data.data + "条结果已通过",
                });
                this.getDataList();
              })
              .catch(() => {
                this.$message.closeAll();
                this.$message({
                  type: "error",
                  message: "提交失败!",
                });
                this.getDataList();
              });
          })
          .catch(() => {
            this.$message.closeAll();
            this.$message({
              type: "info",
              message: "已取消提交",
            });
          });
      } else {
        this.$message.closeAll();
        this.$message({
          type: "info",
          message: "请选择结果通过!",
        });
      }
    },
    //拆分数据
    cutout(cellValue) {
      if (cellValue) {
        var c = cellValue.split(",");
        if (c.size < 1) {
          c.push("-");
          c.push("-");
        } else if (c.size < 2) {
          c.push("-");
        }
        return c;
      }
    },
    //判空
    validatenull(val) {
      return validatenull(val);
    },
    //导出
    exportExcel() {
      var data = this.$refs.reftable.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请选择一个合同！");
        return;
      }
      var ids = [];
      var idlist = [];
      for (var i = 0; i < data.length; i++) {
        ids.push(data[i].htId);
        idlist.push(data[i].htId + "-" + data[i].id);
      }
      console.log(data.length + "===data.length");
      var ndid = 0;
      if (data.length == 1) {
        ndid = data[0].id;
      }
      var filename = "";
      if (ids.length > 1) {
        filename = "业绩合同结果填报.zip";
      } else {
        filename = "业绩合同结果填报" + data[0].contractName + ".xlsx";
      }
      checkSign(ids).then((res) => {
        if (res.data.data == "true") {
          jgtbExportExcel({
            ids: ids,
            idlist: idlist,
            ndid: ndid,
            type: "jgtbs",
          }).then((response) => {
            this.$message.closeAll();
            this.$message.success("导出成功!");
            let url = window.URL.createObjectURL(new Blob([response.data]));
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", filename);
            document.body.appendChild(link);
            link.click();
          });
        } else {
          this.$message.closeAll();
          this.$message.error(res.data.data);
        }
      });
    },
    handleSelectionChange(rows) {
      this.multipleSelection = rows;
    },
    checkboxSelect(row, rowIndex) {
      if (row.contractAuditStatus == 11 || row.contractAuditStatus == 111) {
        return true;
      } else {
        return false;
      }
    },
    contractAuditFormater(row, column) {
      const status = row.contractAuditStatus;
      if (status == 10) {
        return "已归档";
      } else if (status == 11) {
        return "填报中";
      } else if (status == 12) {
        return "结果审核中";
      } else if (status == 13) {
        return "结果汇总完成";
      } else if (status == 14) {
        return "领导审核中";
      } else if (status == 15) {
        return "领导审核完成";
      } else if (status == 16) {
        return "已结束";
      } else if (status == 111) {
        return "填报审核驳回";
      }
    },
    tbFormater(row, column) {
      const status = row.faqiType;
      if (status == 0) {
        return "预填报";
      } else if (status == 1) {
        return "实际填报";
      }
    },
    //切换显示受约人职务和受约人职级
    switchBtn(e) {
      this.shows = e;
      this.rednermsg = false;
      this.$nextTick(() => {
        this.rednermsg = true;
      });
    },
  },
};
</script>
